<#macro category>
<script type="application/javascript">
    function class1List() {
        var tabPanel = 'nav-tab-${shiroUserHelper.getCurrentShiroUser().parentMenuSource.name}';
        $("#" + tabPanel + " #class1Code").empty();
        $("#" + tabPanel + " #class2Code").empty();
        $("#" + tabPanel + " #class3Code").empty();
        $("#" + tabPanel + " #class1Code").append("<option value=''>请选择一级分类</option>");
        $("#" + tabPanel + " #class2Code").append("<option value=''>请选择二级分类</option>");
        $("#" + tabPanel + " #class3Code").append("<option value=''>请选择三级分类</option>");
        var url = '${rc.contextPath}/category/class1List';
        $.ajax({
            url: url,
            type: 'GET',
            contentType: 'application/json',
            dataType: 'json',
            success: function (data) {
                if (data != null) {
                    for (var i = 0; i < data.length; i++) {
                        $("#" + tabPanel + " #class1Code").append("<option value='" + data[i].pcCode + "'>" + data[i].name + "</option>");
                    }
                }
            }
        })
    }

    function class2List(val) {
        var tabPanel = 'nav-tab-${shiroUserHelper.getCurrentShiroUser().parentMenuSource.name}';
        $("#" + tabPanel + " #class2Code").empty();
        $("#" + tabPanel + " #class2Code").append("<option value=''>请选择二级分类</option>");
        $("#" + tabPanel + " #class3Code").empty();
        $("#" + tabPanel + " #class3Code").append("<option value=''>请选择三级分类</option>");
        if (val != '') {
            var url = '${rc.contextPath}/category/class2List/' + val;
            $.ajax({
                url: url,
                type: 'GET',
                contentType: 'application/json',
                dataType: 'json',
                success: function (data) {
                    if (data != null) {
                        for (var i = 0; i < data.length; i++) {
                            $("#" + tabPanel + " #class2Code").append("<option value='" + data[i].pcCode + "'>" + data[i].name + "</option>");
                        }
                    }
                }
            })
        }
    }

    function class3List(val) {
        var tabPanel = 'nav-tab-${shiroUserHelper.getCurrentShiroUser().parentMenuSource.name}';
        $("#" + tabPanel + " #class3Code").empty();
        $("#" + tabPanel + " #class3Code").append("<option value=''>请选择三级分类</option>");
        if (val != '') {
            var url = '${rc.contextPath}/category/class3List/' + val;
            $.ajax({
                url: url,
                type: 'GET',
                contentType: 'application/json',
                dataType: 'json',
                success: function (data) {
                    if (data != null) {
                        for (var i = 0; i < data.length; i++) {
                            $("#" + tabPanel + " #class3Code").append("<option value='" + data[i].pcCode + "'>" + data[i].name + "</option>");
                        }
                    }
                }
            })
        }
    }
</script>
</#macro>